/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.ast;


public class Variable extends TreeNode {

    /**
     * index of id in child list
     */
    private static final int ID_INDEX = 0;

	/**
	 * if <code>true</code>, flagged with an @ symbol; otherwise, <code>false</code>
	 */
	private boolean _flagged;

    /**
     * If the variable has been renamed (to avoid name capture during function inlining),
     * the original variable name.
     */
    public String origName;

    /**
     * Name of {@link Paragraph} in which this variable was declared.
     * Set by {@link alloy.transform.RenameQuantifiedVarsVisitor}.
     * Used for generating {@link alloy.transform.SkolemizationVisitor skolem function} names.
     */
    public QualifiedName paragraphName;
	
    public Variable(Location location_, Id id_, boolean flagged_) {
        super(location_, id_);
        this._flagged = flagged_;
    }


    public Variable(Id id_) {
        super(Location.UNKNOWN, id_);
        this._flagged = false;
    }

	public Variable(Id id_, boolean flagged_) {
		super(Location.UNKNOWN, id_);
		this._flagged = flagged_;
	}


    //GET AND SET METHODS

    /**
     * gets the id of this
     * @return the {@link Id}
     */
    public Id getId() {
        return (Id)childAt(ID_INDEX);
    }

    /** set the Id of this */
    public void setId(Id newChild_) {
        setChild(ID_INDEX, newChild_);
    }

    /**
     * accept an AST visitor
     * @param visitor_ the visitor
     */
    protected void acceptVisitor(ASTVisitor visitor_) {
        visitor_.visit(this);
    }

    /**
     * accept a returning AST visitor
     * @param visitor_ the visitor
     * @return the Object returned by the visitor
     */
    protected Object acceptReturnVisitor(ASTReturnVisitor visitor_) {
        return visitor_.visit(this);
    }

    public String toString()
    {
        return nodeString();
    }

    /**
     * @return
     */
    public boolean isFlagged() {
        return _flagged;
    }

    /**
     * @param b
     */
    public void setFlagged(boolean b) {
        _flagged = b;
    }

}

